/**
 *
 *
 * @author TOTORO
 * @date 2021/6/24 11:15
 */

/**
 * 以下为 输入支付密码的js
 */
$(".sixDigitPassword").find("i").click(function () {
    // 获取第一个没有输入过的i标签
    var that = jQuery;
    $(".sixDigitPassword").find("b").each(function () {
        if($(this).css("visibility") == "hidden"){
            that = $(this).parent();
            return false;
        } else{
            that = $(".sixDigitPassword").find("i[data-id=5]");
        }
    });

    $("#payPassword_rsainput").focus();
    that.addClass("active").siblings().removeClass("active");
    var index = that.data("id");
    $("#flicker").css({"width":"29px", "visibility":"visible"},50);
    $("#flicker").animate({"left":(index*30)+"px"});
});

$("#payPassword_rsainput").keyup(function () {
    console.log($(this).val());
})

$("#payPassword_rsainput").blur(function () {
    $(".active").find("b").css("visibility","hidden");
    $("#flicker").css("visibility","hidden");
    $(".active").removeClass("active");
});

$('#payPassword_rsainput').keyup(function (event) {
    var code = event.which;
    // 如果输入的是f11等等快捷键，则不允许输入
    var not = new Array(9,12,13,16,17,18,20,27,32,33,34,35,36,37,38,39,40,45,46,144,108,112,113,114,115,116,117,
        118,119,120,121,122,123);
    for (let i = 0; i < not.length; i++) {
        if(code == not[i]){
            alert("123")
            return;
        }
    }

    // 如果点击删除
    if(code == 8){
        // 没有删到第一个才可以删除
        if($(".active").data("id")!=0){
            $(".active").find("b").css("visibility","hidden");
            var $prev = $(".active").prev();
            $(".active").removeClass("active");
            $prev.find("b").css("visibility","hidden");
            $prev.addClass("active");
            $("#flicker").css({"width":"29px", "visibility":"visible"});
            $("#flicker").animate({"left":($prev.data("id")*30)+"px"},50);
        }
        return;
    }

    // 如果不是最后一个才可以继续输入
    if($(".active").data("id")<=5) {
        $(".active").find("b").css("visibility", "visible");
        var $next = $(".active").next();
        $next.addClass("active").siblings().removeClass("active");
        $("#flicker").css({"width": "29px", "visibility": "visible"});
        $("#flicker").animate({"left":($next.data("id")*30)+"px"},50);
    }
});
